package com.qjdchina.sku.converter;

import com.qjdchina.sku.model.CaseStoreInfo;
import com.qjdchina.sku.model.vo.CaseStoreInfoVO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Luoyan on 2017/6/11.
 */
public class CaseStoreInfoConverter {

    private CaseStoreInfoConverter(){

    }

    public static CaseStoreInfoVO toCaseStoreInfoVO(CaseStoreInfo caseStoreInfo) {

        CaseStoreInfoVO caseStoreInfoVO = new CaseStoreInfoVO();
        if (null == caseStoreInfo) {
            return caseStoreInfoVO;
        }
        BeanUtils.copyProperties(caseStoreInfo, caseStoreInfoVO);
        return caseStoreInfoVO;
    }

    public static CaseStoreInfo toCaseStoreInfo(CaseStoreInfoVO caseStoreInfoVO) {

        CaseStoreInfo caseStoreInfo = new CaseStoreInfo();
        if (null == caseStoreInfoVO) {
            return caseStoreInfo;
        }
        BeanUtils.copyProperties(caseStoreInfoVO, caseStoreInfo);
        return caseStoreInfo;
    }

    public static List<CaseStoreInfoVO> toCaseStoreInfoVOList(List<CaseStoreInfo> caseStoreInfoList){

        if (null==caseStoreInfoList) {
            return Collections.emptyList();
        }
        List<CaseStoreInfoVO> caseStoreInfoVOList = new ArrayList<CaseStoreInfoVO>();
        for (CaseStoreInfo caseStoreInfo : caseStoreInfoList) {
            caseStoreInfoVOList.add(CaseStoreInfoConverter.toCaseStoreInfoVO(caseStoreInfo));
        }
        return caseStoreInfoVOList;
    }
}
